package org.tmad.ocms.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.log4j.Logger;
import org.tmad.ocms.log.LogFactory;
import org.tmad.ocms.model.Case;
import org.tmad.ocms.model.Volunteer;
import org.tmad.ocms.util.CommonUtils;

@SuppressWarnings("unused")
public class CaseDAO {

	private static Logger logger = LogFactory.getLogger();
	Connection con = null;

	public boolean login(String username, String pwd) throws Exception {
		boolean result = false;

		con = ConnectionManager.getDbConnection();
		Statement stmt = con.createStatement();
		ResultSet results = stmt
				.executeQuery("select * from volunteer where username='" + username
						+ "' and password ='" + pwd + "'");	
		while (results.next()) {
			result = true;
		}
		return result;
	}

	public boolean caseregister(Case user) throws Exception {
		con = ConnectionManager.getDbConnection();
		PreparedStatement stmt = con
				.prepareStatement("insert into casereg(case_category_id,help_category_id , case_summary,case_description,postal_code,city,address,state_id,person_name,contact_mobile,contact_phone,contact_email,case_status_id) values(?,?,?,?,?,?,?,?,?,?,?,?,?)");
		stmt.setString(1, user.getCaseType());
		stmt.setString(2, user.getHelpType());
		stmt.setString(3, user.getSummary());
		stmt.setString(4, user.getDescription());
		stmt.setString(5, user.getNeedyName());
		stmt.setString(6, user.getCity());
		stmt.setString(7, user.getAddress());		stmt.setString(8, user.getState());
		stmt.setString(9, user.getPostalCode());
		stmt.setString(10, user.getMobile());
		stmt.setString(11, user.getContactPhone());
		stmt.setString(12, user.getEmailId());
		stmt.setInt(13, user.getStatusId());
		
				return stmt.execute();
				
	}

	

}
